// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI, { TabPane } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

//引入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble them
Vue.use(VueQuillEditor, /* { default global options } */)

import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

import MyPlugin from "@/MyPlugin"
// import {DatePicker,Button} from 'element-ui' 
// Vue.use(DatePicker);
// Vue.use(Button);
Vue.use(MyPlugin);
Vue.use(ElementUI);

Vue.config.productionTip = false

//使用钩子函数进行权限跳转，没登陆只能加载到登录页面
router.beforeEach((to,from,next)=>{
  Document.title=`${ to.meta.title } | 后端管理系统MMAIL`
  const role=localStorage.getItem("admin");
  if(!role && to.path !=="/login"){
    next("/login")
  }else if(to.meta.permission){//保留有权限页面--超级管理员等
   
    role === "admin" ? next() : next("/403")

  }else{
    //副文本编辑器 ie10才能用
    if(navigator.userAgent.indexOf("MISE") > -1 && to.path === "/edit"){
       alert("副文本编辑器 ie10才能用--组件不兼容")
    }else{
       next();
    }    
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
